// var i;
// var $resKeeper = require("./ResKeeper");
// var $nodePoolMag = require("./NodePoolMag");
// var $buffMag = require("./BuffMag");
// var $uI_MosterLogic = require("./UI_MosterLogic");
// var d = cc._decorator;
// var p = d.ccclass;
// var h = (d.property, d.inspector);
// var f = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.nowbuffdata = null;
//         t.dushanplayer = null;
//         t.nowmoster = [];
//         t.offtime = 0;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.initInfo = function (e, t) {
//         var o = this;
//         this.nowbuffdata = e;
//         this.dushanplayer = t;
//         this.scheduleOnce(function () {
//             o.nowmoster = [];
//             $nodePoolMag.NodePoolMag.instance.recycleNode("duwu", o.node);
//         }, this.nowbuffdata.bufftime);
//     };
//     t.prototype.onCollisionEnter = function (e) {
//         var t = e.node.getComponent($uI_MosterLogic.default);
//         this.nowmoster.push(t);
//     };
//     t.prototype.onCollisionExit = function (e) {
//         var t = e.node.getComponent($uI_MosterLogic.default);
//         var o = this.nowmoster.findIndex(function (e) {
//             return t.node.uuid == e.node.uuid;
//         });
//         this.nowmoster.splice(o, 1);
//     };
//     t.prototype.onUpdate = function (e) {
//         var t = this;
//         this.offtime += e;
//         if (this.offtime >= 1) {
//             this.nowmoster.forEach(function (e) {
//                 var o = $buffMag.BuffMgr.playAttackJiaCheng(t.dushanplayer, t.dushanplayer.sgattack, 1);
//                 e.fujiaAttack(o, 3, t.dushanplayer);
//             });
//             this.offtime = 0;
//         }
//     };
//     return __decorate([p], t);
// })($resKeeper.default);
// exports.default = f;


// import ResKeeper from './ResKeeper';
// import { NodePoolMag } from './NodePoolMag';
// import { BuffMgr } from './BuffMag';
// import UI_MosterLogic from './UI_MosterLogic';

// const { ccclass, property, inspector } = cc._decorator;

// /**
//  * 建议类名: BuffHandler
//  */
// @ccclass
// class UI_DuWu extends ResKeeper {
//     @property
//     private nowBuffData: any = null;

//     @property
//     private dushanPlayer: any = null;

//     @property
//     private nowMoster: any[] = [];

//     @property
//     private offTime: number = 0;

//     /**
//      * 初始化信息
//      * @param buffData - 当前的buff数据
//      * @param player - 玩家对象
//      * 建议方法名: initializeInfo
//      */
//     public initInfo(buffData: any, player: any): void {
//         this.nowBuffData = buffData;
//         this.dushanPlayer = player;
//         this.scheduleOnce(() => {
//             this.nowMoster = [];
//             NodePoolMag.instance.recycleNode("duwu", this.node);
//         }, this.nowBuffData.bufftime);
//     }

//     /**
//      * 碰撞进入事件
//      * @param event - 碰撞事件
//      * 建议方法名: handleCollisionEnter
//      */
//     public onCollisionEnter(event: cc.Collider): void {
//         const monsterLogic = event.node.getComponent(UI_MosterLogic);
//         this.nowMoster.push(monsterLogic);
//     }

//     /**
//      * 碰撞退出事件
//      * @param event - 碰撞事件
//      * 建议方法名: handleCollisionExit
//      */
//     public onCollisionExit(event: cc.Collider): void {
//         const monsterLogic = event.node.getComponent(UI_MosterLogic);
//         const index = this.nowMoster.findIndex((monster) => monster.node.uuid === monsterLogic.node.uuid);
//         this.nowMoster.splice(index, 1);
//     }

//     /**
//      * 更新事件
//      * @param deltaTime - 每帧的时间间隔
//      * 建议方法名: updateHandler
//      */
//     public onUpdate(deltaTime: number): void {
//         this.offTime += deltaTime;
//         if (this.offTime >= 1) {
//             this.nowMoster.forEach((monster) => {
//                 const attackBonus = BuffMgr.playAttackJiaCheng(this.dushanPlayer, this.dushanPlayer.sgattack, 1);
//                 monster.fujiaAttack(attackBonus, 3, this.dushanPlayer);
//             });
//             this.offTime = 0;
//         }
//     }
// }

// export default UI_DuWu;

import ResKeeper from './ResKeeper';
import { NodePoolMag } from './NodePoolMag';
import { BuffMgr } from './BuffMag';
import ViewMosterLogic from './UI_MosterLogic';

const { ccclass, property, inspector } = cc._decorator;

/**
 * 建议类名: BuffHandler
 */
@ccclass
class ViewDuWu extends ResKeeper {
    @property
    private nowBuffData: any = null;

    @property
    private dushanPlayer: any = null;

    @property
    private nowMoster: any[] = [];

    @property
    private offTime: number = 0;

    /**
     * 初始化信息
     * @param buffData - 当前的buff数据
     * @param player - 玩家对象
     * 建议方法名: initializeInfo
     */
    public initializeInfo(buffData: any, player: any): void {
        this.nowBuffData = buffData;
        this.dushanPlayer = player;
        this.scheduleOnce(() => {
            this.nowMoster = [];
            NodePoolMag.instance.recycleNodeToPool("duwu", this.node);
        }, this.nowBuffData.bufftime);
    }

    /**
     * 碰撞进入事件
     * @param event - 碰撞事件
     * 建议方法名: handleCollisionEnter
     */
    public onCollisionEnter(event: cc.Collider): void {
        const monsterLogic = event.node.getComponent(ViewMosterLogic);
        this.nowMoster.push(monsterLogic);
    }

    /**
     * 碰撞退出事件
     * @param event - 碰撞事件
     * 建议方法名: handleCollisionExit
     */
    public onCollisionExit(event: cc.Collider): void {
        const monsterLogic = event.node.getComponent(ViewMosterLogic);
        const index = this.nowMoster.findIndex((monster) => monster.node.uuid === monsterLogic.node.uuid);
        if (index !== -1) {
            this.nowMoster.splice(index, 1);
        }
    }

    /**
     * 更新事件
     * @param deltaTime - 每帧的时间间隔
     * 建议方法名: updateHandler
     */
    public onUpdate(deltaTime: number): void {
        this.offTime += deltaTime;
        if (this.offTime >= 1) {
            this.nowMoster.forEach((monster) => {
                const attackBonus = BuffMgr.applyAttackBonus(this.dushanPlayer, this.dushanPlayer.sgattack, 1);
                monster.fujiaAttack(attackBonus, 3, this.dushanPlayer);
            });
            this.offTime = 0;
        }
    }
}

export default ViewDuWu;